import { defineStore } from 'pinia';

export const useUserStore = defineStore('user', {
  state: () => ({
    userId: '', // 当前用户ID
    username: '', // 用户名
    token: '', // 登录 token
  }),
  actions: {
    setUser(userData) {
      this.userId = userData.userId;
      this.username = userData.username;
      this.token = userData.token;
    },
    clearUser() {
      this.userId = '';
      this.username = '';
      this.token = '';
    },
  },
});